package com.example.backend.service.impl;

import com.example.backend.entity.Company;
import com.example.backend.entity.Port;
import com.example.backend.mapper.PortMapper;
import com.example.backend.service.PortService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PortServiceImpl implements PortService {
    @Autowired
    private PortMapper portMapper;

    @Override
    public int addPort(Port port) {
        return portMapper.insert(port);
    }

    @Override
    public Port getPortById(Long id) {
        return portMapper.selectById(id);
    }

    @Override
    public List<Port> getAllPorts() {
        return portMapper.selectAll();
    }

    @Override
    public int updatePort(Port port) {
        return portMapper.update(port);
    }

    @Override
    public int deletePort(Long id) {
        return portMapper.deleteById(id);
    }

    @Override
    public List<Company> getCompaniesByPortId(Long portId) {
        return portMapper.selectCompaniesByPortId(portId);
    }

    @Override
    public int addPortCompany(Long portId, Long companyId) {
        return portMapper.insertPortCompany(portId, companyId);
    }

    @Override
    public int removePortCompany(Long portId, Long companyId) {
        return portMapper.deletePortCompany(portId, companyId);
    }
} 